'use client'

import { useSearchParams } from 'next/navigation'
import { Suspense, useEffect } from 'react'
import Image from 'next/image'
import LogoImage from '@/images/logo.png'

const RedirectUrl = () => {
  const searchParams = useSearchParams()

  useEffect(() => {
    const url = searchParams.get('u')

    setTimeout(() => {
      window.location.href = url
    }, 1500)
  }, [])

  return (
    <div className="flex justify-center items-center w-lvh h-lvh">
      <Image className="animate-bounce" src={LogoImage} width={100} alt="RedGrowth" />
    </div>
  )
}

export default function Url() {
  return (
    <Suspense>
      <RedirectUrl />
    </Suspense>
  )
}
